import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-15
 * Time: 8:28
 */
public class Test {
    /*public static void main9(String[] args) {
        char ch1 = 'a';
        char ch2 =(char)(ch1-32);
        System.out.println(ch2);
    }*/

    /*public static void main8(String[] args) {
        //1.spilt分割
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] str1 = str.split(" ");
        int count = str1[str1.length - 1].length();
        System.out.println(count);

        //2.lastIndexof -> subString
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int i = str.lastIndexOf(" ");
        String str2 = str.substring(i+1);
        System.out.println(str2.length());

        //3.自己实现
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int space = 0,j = str.length();
        for(int i = 0; i < j; i++) {
            if(str.charAt(i) == ' ') {
                space = i;
            }
        }
        if(space != 0) {
            System.out.println(j - space - 1);
        }else {
            System.out.println(j);
        }
    }

    public int firstUniqChar(String s) {
        int[] count = new int[26];
        for(int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'a']++;
        }
        for(int i = 0; i < s.length(); i++) {
            if(count[s.charAt(i) - 'a'] == 1) {
                return i;
            }
        }
        return -1;
    }*/

    /*public static void main7(String[] args) {
        long start = System.currentTimeMillis();
        String s = "";
        for(int i = 0; i < 10000; ++i){
            s += i;
        } long end = System.currentTimeMillis();
        System.out.println("String " + (end - start));

        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for(int i = 0; i < 10000; ++i){
            sbf.append(i);
        } end = System.currentTimeMillis();
        System.out.println("StringBuffer " + (end - start));

        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder();
        for(int i = 0; i < 10000; ++i){
            sbd.append(i);
        } end = System.currentTimeMillis();
        System.out.println("StringBuilder " + (end - start));
    }*/

    /*public static void main6(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("a");
    }*/

    /*public static void main5(String[] args) {
        String str = "hello ";
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(str);
        for(int i = 0 ; i < 1; i++) {
            stringBuilder.append("hello");
        }
        str = stringBuilder.toString();
        System.out.println(str);
    }*/

    /*public static void main4(String[] args) {
        String str = "Hello ";
        str += "world";

        System.out.println(str);
    }*/

    /*public static void main3(String[] args) {
        final int[] Array = {1,2,3,4};
        System.out.println(Arrays.toString(Array));
        //Array[0] = 99;
        //Array =new int[]{55,44,99,88};
        System.out.println(Arrays.toString(Array));
    }*/

    /*public static void main2(String[] args) {
        String str = "          absd   fff  cc     ";
        System.out.println(str);
        String str1 = str.trim();
        System.out.println("=================");
        System.out.println(str1);
    }*/

    /*public static void main1(String[] args) {
        String str1 = "abcdef";
        String str2 = str1.substring(1);
        System.out.println(str2);
        System.out.println("=================");
        String str3 = str1.substring(1,3);
        System.out.println(str3);
    }*/
}

class Solution {
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        int left = 0,right = s.length() - 1;
        while(left < right) {
            while(left < right && !isNumCharacter(s.charAt(left))) {
                left++;
            }
            while(left < right && !isNumCharacter(s.charAt(right))) {
                right--;
            }

            if(s.charAt(left) == s.charAt(right)) {
                left++;
                right--;
            }else {
                return false;
            }
        }
        return true;

    }
    private boolean isNumCharacter(char ch) {
        if((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')) {
            return true;
        }
        return false;
    }
}
